<!DOCTYPE HTML>
<html>
<head>
<script src="/js-test-resources/js-test.js"></script>
<script>
description("Test that a linked stylesheet with a crossorigin=anonymous attribute loads a CORS enabled resource.");
</script>
<script src="resources/link-crossorigin-common.js"></script>
</head>
<link crossorigin="anonymous" rel="stylesheet" href="http://localhost:8080/security/resources/green-background-allow-star.php" onload="pass(event)" onerror="fail(event)">
<link crossorigin="anonymous" rel="stylesheet" href="http://localhost:8080/security/resources/green-background-allow-credentials.php" onload="pass(event)" onerror="fail(event)">
<script>
function runTest()
{
    // Test that dynamically inserted <link> elements are handled the same way.
    var link = document.createElement("link");
    link.rel = "stylesheet";
    link.crossOrigin = "anonymous";
    link.onload = pass;
    link.onerror = fail;
    link.href = "http://localhost:8080/security/resources/green-background-allow-star.php";
    document.body.appendChild(link);

    link = document.createElement("link");
    link.rel = "stylesheet";
    link.crossOrigin = "use-credentials";
    link.onload = pass;
    link.onerror = fail;
    link.href = "http://localhost:8080/security/resources/green-background-allow-credentials.php";
    document.body.appendChild(link);
}
window.onload = runTest;
</script>
</body>
</html>
